import Vue from "vue";
import VueRouter, { RouteConfig } from "vue-router";

Vue.use(VueRouter);
export const routeMapping = {
  Login: "Login",
  unAuth: "unAuth",
  DashBoard: "01000000",
  PendingJob: "02000000",
  Customer: {
    name: "04000000",
    ContactInfo: "ContactInfo",
    ProspectCustomer: "ProspectCustomer",
    ExistingCustomer: "ExistingCustomer",
  },
  Project: "07000000",
  Maintenance: {
    name: "10000000",
    Setting: {
      name: "Setting",
      Country: "Country",
      MessageInfo: "Message Info",
      Holiday: "Holiday",
      Team: "Team",
      ContactType: "Contact Type",
      ProjectType: "Project Type",
      ProblemType: "Problem Type",
      ItemType: "Item Type",
      ExpenseType: "Expense Type",
    },
    Admin: {
      name: "Admin",
      User: "User",
      Device: "Device",
      UserGroupRight: "User Group Right",
      DocumentApproval: "Document Approval",
      Attendance: "Attendance",
    },
  },
  Library: "13000000",
  Kiosk: "21000000",
  JobSheet: "11000000",
  Quotation: "03000000",
  Invoice: "08000000",
};

const routes: Array<RouteConfig> = [
  {
    path: "/",
    name: routeMapping.Login,
    component: () => import("@/views/Login/Login.vue"),
  },
  {
    path: "/Dashboard",
    name: routeMapping.DashBoard,
    component: () => import("@/views/01000000-Dashboard/Dashboard.vue"),
    meta: {
      menuTitle: "DashBoard",
    },
  },
  {
    path: "/PendingJob",
    name: routeMapping.PendingJob,
    component: () => import("@/views/02000000-PendingJob/index.vue"),
    meta: {
      menuTitle: "PendingJob",
    },
  },
  {
    path: "/Customer",
    name: routeMapping.Customer.name,
    component: () => import("@/views/04000000-Customer/Customer.vue"),
    meta: {
      sliderMenu: true,
      menuTitle: "Customer",
    },
    redirect: {
      name: routeMapping.Customer.ExistingCustomer,
    },
    children: [
      {
        path: "ExistingCustomer",
        name: routeMapping.Customer.ExistingCustomer,
        component: () =>
          import(
            "@/views/04000000-Customer/ExistingCustomer/ExistingCustomer.vue"
          ),
        meta: {
          sliderMenu: true,
        },
      },
      {
        path: "ContactInfo",
        name: routeMapping.Customer.ContactInfo,
        component: () =>
          import("@/views/04000000-Customer/ContactInfo/ContactInfo.vue"),
        meta: {
          sliderMenu: false,
        },
      },
      {
        path: "ProspectCustomer",
        name: routeMapping.Customer.ProspectCustomer,
        component: () =>
          import(
            "@/views/04000000-Customer/ProspectCustomer/ProspectCustomer.vue"
          ),
        meta: {
          sliderMenu: true,
        },
      },
      {
        path: "*",
        redirect: {
          name: "ExistingCustomer",
        },
      },
    ],
  },
  {
    path: "/Project",
    name: routeMapping.Project,
    component: () => import("@/views/07000000-Project/Project.vue"),
    meta: {
      menuTitle: "Project",
    },
  },
  {
    path: "/Maintenance",
    name: routeMapping.Maintenance.name,
    component: () => import("@/views/10000000-Maintenance/Maintenance.vue"),
    meta: {
      menuTitle: "Maintenance",
    },
    redirect: {
      name: "Message Info",
    },
    children: [
      {
        path: "Setting",
        name: routeMapping.Maintenance.Setting.name,
        component: () =>
          import("@/views/10000000-Maintenance/Setting/Setting.vue"),
        redirect: {
          name: "Message Info",
        },
        children: [
          {
            path: "MessageInfo",
            name: routeMapping.Maintenance.Setting.MessageInfo,
            component: () =>
              import(
                "@/views/10000000-Maintenance/Setting/MessageInfo/MessageInfo.vue"
              ),
          },
          {
            path: "Country",
            name: routeMapping.Maintenance.Setting.Country,
            component: () =>
              import(
                "@/views/10000000-Maintenance/Setting/Country/Country.vue"
              ),
          },
          {
            path: "Holiday",
            name: routeMapping.Maintenance.Setting.Holiday,
            component: () =>
              import(
                "@/views/10000000-Maintenance/Setting/Holiday/Holiday.vue"
              ),
          },
          {
            path: "Team",
            name: routeMapping.Maintenance.Setting.Team,
            component: () =>
              import("@/views/10000000-Maintenance/Setting/Team/Team.vue"),
          },
          {
            path: "ContactType",
            name: routeMapping.Maintenance.Setting.ContactType,
            component: () =>
              import(
                "@/views/10000000-Maintenance/Setting/ContactType/ContactType.vue"
              ),
          },
          {
            path: "ProjectType",
            name: routeMapping.Maintenance.Setting.ProjectType,
            component: () =>
              import(
                "@/views/10000000-Maintenance/Setting/ProjectType/ProjectType.vue"
              ),
          },
          {
            path: "ProblemType",
            name: routeMapping.Maintenance.Setting.ProblemType,
            component: () =>
              import(
                "@/views/10000000-Maintenance/Setting/ProblemType/ProblemType.vue"
              ),
          },
          {
            path: "ItemType",
            name: routeMapping.Maintenance.Setting.ItemType,
            component: () =>
              import(
                "@/views/10000000-Maintenance/Setting/ItemType/ItemType.vue"
              ),
          },
          {
            path: "ExpenseType",
            name: routeMapping.Maintenance.Setting.ExpenseType,
            component: () =>
              import(
                "@/views/10000000-Maintenance/Setting/ExpenseType/ExpenseType.vue"
              ),
          },
          {
            path: "*",
            redirect: {
              name: "Message Info",
            },
          },
        ],
      },
      {
        path: "Admin",
        name: routeMapping.Maintenance.Admin.name,
        component: () => import("@/views/10000000-Maintenance/Admin/Admin.vue"),
        children: [
          {
            path: "User",
            name: routeMapping.Maintenance.Admin.User,
            component: () =>
              import("@/views/10000000-Maintenance/Admin/User/User.vue"),
          },
          {
            path: "Device",
            name: routeMapping.Maintenance.Admin.Device,
            component: () =>
              import("@/views/10000000-Maintenance/Admin/Device/Device.vue"),
          },
          {
            path: "UserGroupRight",
            name: routeMapping.Maintenance.Admin.UserGroupRight,
            component: () =>
              import(
                "@/views/10000000-Maintenance/Admin/UserGroupRight/UserGroupRight.vue"
              ),
          },
          {
            path: "DocumentApproval",
            name: routeMapping.Maintenance.Admin.DocumentApproval,
            component: () =>
              import(
                "@/views/10000000-Maintenance/Admin/DocumentApproval/DocumentApproval.vue"
              ),
          },
          {
            path: "Attendance",
            name: routeMapping.Maintenance.Admin.Attendance,
            component: () =>
              import(
                "@/views/10000000-Maintenance/Admin/Attendance/Attendance.vue"
              ),
          },
          {
            path: "*",
            redirect: {
              name: "User",
            },
          },
        ],
      },
      {
        path: "*",
        redirect: {
          name: "Message Info",
        },
      },
    ],
  },
  {
    path: "/Library",
    name: routeMapping.Library,
    component: () => import("@/views/13000000-Library/index.vue"),
    meta: {
      menuTitle: "Library",
    },
  },
  {
    path: "/Kiosk",
    name: routeMapping.Kiosk,
    component: () => import("@/views/21000000-Kiosk/index.vue"),
    meta: {
      menuTitle: "Kiosk",
    },
  },
  {
    path: "/JobSheet",
    name: routeMapping.JobSheet,
    component: () => import("@/views/11000000-JobSheet/index.vue"),
    meta: {
      menuTitle: "Job Sheet",
    },
  },
  {
    path: "/Quotation",
    name: routeMapping.Quotation,
    component: () => import("@/views/03000000-Quotation/index.vue"),
    meta: {
      menuTitle: "Quotation",
    },
  },
  {
    path: "/Invoice",
    name: routeMapping.Invoice,
    component: () => import("@/views/08000000-Invoice/index.vue"),
    meta: {
      menuTitle: "Invoice",
    },
  },
  {
    path: "*",
    component: () => import("@/views/AboutView.vue"),
  },
];

export const router = new VueRouter({
  mode: "history",
  routes,
});
